<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>e网批发管理后台</title>
    <?php include("common/conn.php"); if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 
    if($_GET['action']=="ok")
    {    

        if (empty($_POST[name]) || empty($_POST[city])) {
             echo "<script>alert('小区名称和小区地址不能为空!');window.location.href='addcity.php';</script>";
             exit();
        }
        $date=date("Y-m-d h:i:s");
        $srat=mysql_query("INSERT INTO city(name,city,latitude,longitude) VALUES ('$_POST[name]','$_POST[city]','$_POST[weidu]','$_POST[jingdu]')");

        echo "<script>window.location.href='city.php';</script>";
    }

    if($_GET['id']!=""){
        $rert30=mysql_query("select * from city where id='".$_GET['id']."'");
        $sdg30=mysql_fetch_array($rert30);
    }


    if($_GET['ch']=="ok")
    {    
        if (empty($_POST[name]) || empty($_POST[city])) {
             echo "<script>alert('小区名称和小区地址不能为空!');window.location.href='addcity.php?id=$_REQUEST[id]';</script>";
             exit();
        }
        $srat1=mysql_query("update city set name='".$_POST['name']."',city='".$_POST['city']."',latitude='".$_POST['weidu']."',longitude='".$_POST['jingdu']."' where id='".$_REQUEST['id']."'");

        echo "<script>window.location.href='city.php';</script>";
    }


    ?>
    <script type="text/javascript" src="js/jquery.min.js"></script>

    <!-- MASTER STYLESHEET-->
    <link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>

    <!--header-->
    <?php include("common/header.php");?>
    <!--header end-->

    <div class="container_12">
        <form action="?<?php if($_GET['id']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post">
            <h2>添加小区</h2>  	
            <table width="100%" border="0" cellpadding="0" cellspacing="0">

                <!--收货信息-->
                <div class="car_mode" >

                    <div class="indexfloat" style="width:15%; margin-left:5%;">
                        小区地址
                    </div> 
                    <div class="indexfloat" style="width:79%;">
                        <a href="gruop_location2.php?id=<?php echo $_GET[id]; ?>">
                        <input type="text" class="text" name="city" id="ea55_title"  value="<?php if ($_REQUEST[title]!='') {echo $_REQUEST[title];}elseif ($sdg30[city]!='') {echo $sdg30[city];} ?>" autocomplete="off" x-webkit-speech="" speech="" style=" width:200px;"  class="ea55_posts" placeholder="<?php if($_REQUEST['title']!=""){echo $_REQUEST['title'];}else{echo "点击获取地址";}?>"></a>
                        <?php if (!empty($_REQUEST[id]) || $_REQUEST['jingdu'] !='') { ?>
                        经度:<input type="text" class="text" readonly="readonly" value="<?php if ($_REQUEST[jingdu]!=''){
                            echo $_REQUEST[jingdu];
                        }elseif ($sdg30[longitude]!='') {
                            echo $sdg30[longitude];
                        } ?>"> 
                        纬度:<input type="text" class="text" readonly="readonly" value="<?php if ($_REQUEST[weidu]!=''){
                            echo $_REQUEST[weidu];
                        }elseif ($sdg30[latitude]!='') {
                            echo $sdg30[latitude];
                        } ?>"> 
                        <?php } ?>
                    </div>
                        			   
                </div>


                <input name="jingdu" type="hidden"  value="<?php if($_REQUEST['jingdu']!=""){echo $_REQUEST['jingdu'];}else{echo $sdg30[longitude];}?>" autocomplete="off" x-webkit-speech="" speech="" style=" width:200px;"  class="ea55_posts" placeholder="<?php if($_REQUEST['jingdu']!=""){echo $_REQUEST['jingdu'];}else{echo "点击获取地址";}?>"><input type="hidden" name="weidu"   value="<?php if($_REQUEST['weidu']!=""){echo $_REQUEST['weidu'];}else{echo $sdg30[latitude];}?>" autocomplete="off" x-webkit-speech="" speech="" style=" width:200px;"  class="ea55_posts" placeholder="<?php if($_REQUEST['weidu']!=""){echo $_REQUEST['weidu'];}else{echo "点击获取地址";}?>">
                <!--收货信息-->
                <!--收货信息-->

                <div class="car_mode" >

                    <div class="indexfloat" style="width:15%; margin-left:5%;">
                        小区名称
                    </div> 
                    <div class="indexfloat" style="width:79%;">
                        <input type="text" name="name" class="text" value="<?php echo $sdg30[name]; ?>">
                    </div>                          
                </div>

                <div class="car_mode" >
                    <input name="id" type="hidden" value="<?php echo $_GET[id];?>" /><input name="" type="submit" value="提交" />
                </div>


            </table>
        </form>


    </div>

</form>
</body>
</html>
